GEM5_SIMULATOR   =  ./build/RISCV/gem5.opt

BOOMFLAGS     +=  --debug-flags=CacheMiss \
          --debug-file=trace.out \
          configs/aware_prefetch/se.py \
          --cpu-type=RiscvO3CPU \
          --bp-type=BiModeBP \
          --caches \
          --l2cache \
          --cacheline=64 \
          --num-l2cache=1 \
          --l1i_size=64kB \
          --l1i_assoc=4 \
          --l1d_size=16kB \
          --l1d_assoc=4 \
		  --l1d-hwp-type=AFPrefetcher\
          --l2_size=256kB \
          --l2_assoc=4 \
          --mem-size=8192MB

ATTACK_HOME=/home/jiangfang/workspace/riscv-fs/attack_home/spectre_on_gem5
run: 
	$(GEM5_SIMULATOR) $(BOOMFLAGS) $(BIN)

# run spectre-v1
smix:
	$(GEM5_SIMULATOR) $(BOOMFLAGS) --cmd=$(ATTACK_HOME)/bin/smix.riscv


# run spectre-v1
s1:
	$(GEM5_SIMULATOR) $(BOOMFLAGS) --cmd=$(ATTACK_HOME)/bin/spectre-v1.riscv

# run spectre-v2
s2:
	$(GEM5_SIMULATOR) $(BOOMFLAGS) --cmd=$(ATTACK_HOME)/bin/spectre-v2.riscv

s4:
	$(GEM5_SIMULATOR) $(BOOMFLAGS) --cmd=$(ATTACK_HOME)/bin/spectre-v4.riscv

s5:
	$(GEM5_SIMULATOR) $(BOOMFLAGS) --cmd=$(ATTACK_HOME)/bin/spectre-v5.riscv

s1mix:
	$(GEM5_SIMULATOR) $(BOOMFLAGS) --cmd=$(ATTACK_HOME)/bin/spectre-v1-mix.riscv

s2mix:
	$(GEM5_SIMULATOR) $(BOOMFLAGS) --cmd=$(ATTACK_HOME)/bin/spectre-v2-mix.riscv

s4mix:
	$(GEM5_SIMULATOR) $(BOOMFLAGS) --cmd=$(ATTACK_HOME)/bin/spectre-v4-mix.riscv

s5mix:
	$(GEM5_SIMULATOR) $(BOOMFLAGS) --cmd=$(ATTACK_HOME)/bin/spectre-v5-mix.riscv


run-spectre:s1 s2 s4 s5
run-inorder: s1 s2 s4 s5
run-mix:s1mix s2mix s4mix s5mix

# build gem5.opt
build:
	scons build/RISCV/gem5.opt -j17